#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<bool> vec(2000000002,false);
int longestConsecutive(vector<int>& nums) {

        int max = INT_MIN,min = INT_MAX;
        for(auto n: nums)
        {
            n += 1000000000;
            vec[n] = true;
            max = n > max ? n : max;
            min = n < min ? n : min;
        }
        int ans = 0;
        int tmp = 0;
        for(int i = min ; i <= max ; i++)
        {
            if(vec[i])
            {
                tmp++;
            }
            else{
                ans = tmp > ans ? tmp : ans;
                tmp = 0;
            }
        }
        ans = tmp > ans ? tmp : ans;
        return ans;
    }
int main() {
    vector<int> nums{7,-2,9,9,1,9,8,-4,6,-6,-6,4,1,3,6,3,5,-2,3,4,-6,1,5,-9,6,1,2,-2,1};
    cout << longestConsecutive(nums);
    return 0;
}